package com.example.park2212.adapter

import androidx.databinding.DataBindingUtil
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.viewholder.BaseViewHolder
import com.example.lib_base.entity.VisitBeanItem
import com.example.park2212.R
import com.example.park2212.databinding.ItemVisitBinding

class VisitAdapter:BaseQuickAdapter<VisitBeanItem,BaseViewHolder>(R.layout.item_visit) {
    lateinit var binding:ItemVisitBinding

    override fun onItemViewHolderCreated(viewHolder: BaseViewHolder, viewType: Int) {
        super.onItemViewHolderCreated(viewHolder, viewType)
        DataBindingUtil.bind<ItemVisitBinding>(viewHolder.itemView)
    }
    override fun convert(helper: BaseViewHolder, item: VisitBeanItem) {
        binding =  DataBindingUtil.bind<ItemVisitBinding>(helper.itemView)!!
        binding.bean = item

        val tv_status = binding.visitStatus
        if (item.visitStatus == "已通过"){
            tv_status.setTextColor(context.getColor(R.color.green))
            tv_status.setBackgroundResource(R.drawable.shape_status)
        } else if (item.visitStatus == "待审核"){
            tv_status.setTextColor(context.getColor(R.color.blue))
            tv_status.setBackgroundResource(R.drawable.shape_zhanyong)
        } else if(item.visitStatus == "驳回"){
            tv_status.setTextColor(context.getColor(R.color.orange))
            tv_status.setBackgroundResource(R.drawable.shape_weihu)
        }else{
            tv_status.setTextColor(context.getColor(R.color.darkgray))
            tv_status.setBackgroundResource(R.drawable.shape_zhanyong)
        }

        if (item.requestParking){
            binding.visitImg.setImageResource(R.drawable.ic_action_car)
        }
    }


}